﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Cashier.utils;
using System.IO;

namespace Cashier.help
{
    public partial class AboutForm : Form
    {
        public AboutForm()
        {
            InitializeComponent();
            label_version.Text = ToolsUtil.GetMainProgramVersion();
        }

        /// <summary>
        /// 重写键盘事件
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            bool b = base.ProcessCmdKey(ref msg, keyData);
            switch (keyData)
            {
                case Keys.Escape:
                    this.Close();
                    break;
            }
            return b;
        }

        /// <summary>
        /// 关闭窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// 升级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_upgrade_Click(object sender, EventArgs e)
        {
            String path = System.Windows.Forms.Application.StartupPath + @"\update.exe";
            FileInfo fileInfo = new FileInfo(path);
            if (fileInfo.Exists)
            {
                System.Diagnostics.Process.Start(path);
            }
            else
            {
                MessageBox.Show("升级程序不存在！");
            }
        }
    }
}
